package tvv.levelup;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import tvv.levelup.controller.PetType;
import tvv.levelup.models.Pet;
import tvv.levelup.controller.PetManager;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by VLAD on 02.09.2014.
 */
public class main {
    public static void main(String args[]){

        ApplicationContext ac = new FileSystemXmlApplicationContext("./config/ApplicationContext.xml");
        PetManager pm = ac.getBean(PetManager.class);

        pm.saveEquipment("eq1");
        pm.saveEquipment("eq2");
        pm.saveEquipment("eq3");
        pm.saveEquipment("eq4");

        pm.createPet(PetType.CAT);
        pm.createPet(PetType.DOG);
        pm.createPet(PetType.CAT);

        try {
            pm.deletePet(pm.getPetById(1));
        } catch (Exception e){
            System.err.println("The pet can't be deleted ");
        }


        List<Integer> newEquipment = new LinkedList();
        newEquipment.add(2);
        newEquipment.add(3);
        newEquipment.add(4);
        Pet pet4 = pm.getPetById(3);
        System.out.println(pet4);
        pm.changePetEquipment(pet4, newEquipment);
        System.out.println(pet4);

    }
}
